package com.aspose.cells;

class zasy implements zahj {
   private int a;
   private zrr b;
   private zrr c;
   private double d = 0.0D;
   private double e = 0.0D;

   zasy(int var1, int var2) {
      this.a = var1;
      this.b = new zrr(var2 < 100 ? var2 : var2 / 2, 0);
      this.c = new zrr(this.b.b().length, 0);
   }

   public zagu a(double var1, double var3) {
      this.b.a(var1);
      this.c.a(var3);
      this.d = (this.d * ((double)this.b.a() - 1.0D) + var1) / (double)this.b.a();
      this.e = (this.e * ((double)this.c.a() - 1.0D) + var3) / (double)this.c.a();
      return null;
   }

   public zagu a(double var1, double var3, int var5) {
      this.d = (this.d * (double)this.b.a() + var1 * (double)var5) / (double)(this.b.a() + var5);
      this.d = (this.e * (double)this.c.a() + var3 * (double)var5) / (double)(this.c.a() + var5);
      this.b.a(var1, var5);
      this.c.a(var3, var5);
      return null;
   }

   public zagu a() {
      int var1 = this.b.a();
      double var2;
      int var4;
      switch(this.a) {
      case 307:
         if (var1 < 2) {
            return zza.a;
         }
         break;
      case 308:
      case 514:
         if (var1 < 1) {
            return zza.a;
         }

         var2 = 0.0D;

         for(var4 = 0; var4 < var1; ++var4) {
            var2 += (this.b.a(var4) - this.d) * (this.c.a(var4) - this.e);
         }

         return new zyy(var2 / (double)var1);
      case 314:
         if (var1 < 3) {
            return zza.a;
         }
         break;
      case 515:
         if (var1 < 2) {
            return zza.a;
         }

         var2 = 0.0D;

         for(var4 = 0; var4 < var1; ++var4) {
            var2 += (this.b.a(var4) - this.d) * (this.c.a(var4) - this.e);
         }

         return new zyy(var2 / ((double)var1 - 1.0D));
      }

      var2 = 0.0D;
      double var13 = 0.0D;
      double var6 = 0.0D;

      for(int var8 = 0; var8 < var1; ++var8) {
         double var9 = this.b.a(var8) - this.d;
         double var11 = this.c.a(var8) - this.e;
         var2 += var9 * var11;
         var13 += var9 * var9;
         var6 += var11 * var11;
      }

      switch(this.a) {
      case 307:
         if (var13 != 0.0D && var6 != 0.0D) {
            return zaaq.a(var2 / Math.sqrt(var13) / Math.sqrt(var6));
         }

         return zza.a;
      case 314:
         if (var13 == 0.0D) {
            return zza.a;
         }

         return zaaq.a(Math.sqrt((var13 - var2 * var2 / var6) / (double)(var1 - 2)));
      default:
         return zzk.a;
      }
   }

   public zagu b() {
      return zza.a;
   }
}
